Repository navigation
Add a refactoring between namespace + nested module and root module - #20536
xperiandri wants to merge 9 commits into
Conversation
✅ Release notes checked
|
e51d4cd to
7863f7e
Compare
5f7ae33 to
afc3127
Compare
This comment has been minimized.
This comment has been minimized.
T-Gro
left a comment
There was a problem hiding this comment.
🤖🕵️ Please shorten the description using this guidance. Focus on the problem and why the change is needed, in simplified technical English. Leave the implementation inventory to the Files tab and retain necessary caveats.
namespace + nested module and root module
Covered casesConverts
Not offered
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Pushed c3aadc7: the 21 implementation comment lines of the refactoring and the 2 in its tests are gone, so the PR adds one comment line, the license header (24 comment lines and 2273 characters before). What they said is in names and small functions now: |
T-Gro
left a comment
There was a problem hiding this comment.
🤖🕵️ AI review — verify independently.
From dotnet#20536: a comment between the namespace and the opens left the opens in place next to their copies under the new header. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This branch had only the copy without the PR link. It gives way to the bullet the PR keeps (50669a2 of dotnet#20536). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…them Port of the dotnet#20536 compaction (feature/namespace-module-refactoring e610d0f..c3aadc7) to all-fixes. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
From dotnet#20536: a comment between the namespace and the opens left the opens in place next to their copies under the new header. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This branch had only the copy without the PR link. It gives way to the bullet the PR keeps (50669a2 of dotnet#20536). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…them Port of the dotnet#20536 compaction (feature/namespace-module-refactoring e610d0f..c3aadc7) to all-fixes. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
From dotnet#20536: a comment between the namespace and the opens left the opens in place next to their copies under the new header. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This branch had only the copy without the PR link. It gives way to the bullet the PR keeps (50669a2 of dotnet#20536). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…them Port of the dotnet#20536 compaction (feature/namespace-module-refactoring e610d0f..c3aadc7) to all-fixes. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
From dotnet#20536: a comment between the namespace and the opens left the opens in place next to their copies under the new header. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This branch had only the copy without the PR link. It gives way to the bullet the PR keeps (50669a2 of dotnet#20536). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…them Port of the dotnet#20536 compaction (feature/namespace-module-refactoring e610d0f..c3aadc7) to all-fixes. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
From dotnet#20536: a comment between the namespace and the opens left the opens in place next to their copies under the new header. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This branch had only the copy without the PR link. It gives way to the bullet the PR keeps (50669a2 of dotnet#20536). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…them Port of the dotnet#20536 compaction (feature/namespace-module-refactoring e610d0f..c3aadc7) to all-fixes. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
c3aadc7 to
68dd6e8
Compare
…ot-level module With the caret on the header, 'namespace A.B' holding a single 'module C =' converts to 'module A.B.C', and 'module A.B.C' converts back. The compiler treats the two forms as the same module, so the edit only rewrites the header and moves the body by the nested module's indentation; lines inside multi-line string literals keep their text. Files with a signature file are not offered the conversion, because converting one side would unpair it from the other. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The namespace line and the opens were deleted as one block ending at the first kept line, so a comment between the namespace and the opens left the opens in place while copies were added under the new header. Each of them is now deleted on its own, with the blank lines after it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…e of its section Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…enting The lines the conversion shifts now skip lines inside multi-line strings of inactive branches, found by lexing each inactive branch as the code it is when taken. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…bute would not survive it Converting a namespace with one nested module to a root module is no longer offered when - an `#if` stands on or above the module header line. The tree shows only what the active branches hold, so a `type` or an `open` in another branch stayed above `module A.B.C`, and the file broke once that branch was taken; - an attribute of the module resolves a name through an `open` that moves below the header. The attributes of a root module are checked above those opens, so the file is type-checked and each name the attributes look up has to resolve to the same symbol at the namespace line; - anything but a line comment follows a moved `open` on its line. A line comment after a moved `open` now moves with it instead of being deleted with the line. In an inactive branch, a line that reads like a directive inside a multi-line string no longer resets the tokenizer that tracks the string, so the lines after it keep their indentation like the rest of the literal. The tests now type-check every converted document. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…them Delete the implementation comments (21 lines in the refactoring, 2 in its tests) and let names, functions and the complement of a predicate carry what they said: - hasIfDirectiveOnOrAbove and isDirectiveRecognizedWhileSkipping name the two directive checks - startsInsideString is the complement of isCodeCommentOrSkippedState, so the string states the public enum does not name need no remark - tokenizerWithDefines / tokenizerAsIfBranchTaken and their states say how linesInsideInactiveLiterals lexes an inactive branch - isNamedArgumentTarget and isConstantOperator split attributesKeepMeaningAt (was attributesResolveAt) into its two exemptions - removedLineRangesWithBlankLinesAfter and insertOpensBelowHeader are the two steps of the namespace-to-root-module edit that had a comment each Behaviour is unchanged. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Replaying the branch onto main left some files short of the branch's own content; this restores it. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… name over several lines A `namespace` with no identifier made the shape check call List.last on an empty list, so Ctrl+. threw. A name split over lines (`namespace A.` then `B` below) left the second part behind when the header line was removed, which does not parse. Both now offer no conversion. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
68dd6e8 to
5298973
Compare
5298973 to
5abae71
Compare
| (HashSet<int>(), parseTree) | ||
| ||> ParsedInput.fold (fun lines _ node -> | ||
| match node with | ||
| | SyntaxNode.SynExpr(SynExpr.Const(range = m)) |
There was a problem hiding this comment.
🤖🕵️ Re-indents multi-line strings in attribute / TP args, so the value changes:
// before
module C =
[<Obsolete("""a
b""")>]
// after
[<Obsolete("""a
b""")>]Fix: find string lines by tokenizer only, drop ParsedInput.fold.
There was a problem hiding this comment.
@xperiandri would you be able to fix this finding soon? Let's get this PR merged :)
Offers
Ctrl+.on the header to turnnamespace A.Bwith a single nestedmodule C =intomodule A.B.C, and back.opens before the nested module move under the new header; the body is re-indented line by line, leaving multi-line strings alone.Not offered when the namespace holds anything besides leading
opens and the module, or when the file has a paired.fsi(the signature would stop matching, FS0240).🤖 Generated with Claude Code